﻿using System;
using Blazing.BusinessObjects.Products;
using Blazing.WebFacade;
using System.Linq;
using Blazing.BusinessObjects.Tagging;
using System.Collections.Generic;
using Blazing.BusinessObjects.Queries;
using Blazing.BusinessObjects.Assets;

namespace Blazing.WebShop.UserControls
{
    public partial class ProductImage : System.Web.UI.UserControl
    {
        public Product ProductFor { get; set; }
        public string TagSlugs { get; set; }

        public override void DataBind()
        {
            base.DataBind();

            if (ProductFor == null)
            {
                ImageProduct.Visible = false;
                return;
            }

            IList<Asset> list = new ProductsController().GetProductImagesBySlugs(ProductFor, TagSlugs);
            if (list != null && list.Count > 0)
            {
                ImageProduct.Visible = true;
                ImageProduct.ImageUrl = list[0].FilePath + list[0].FileName;
            }
            else
            {
                ImageProduct.Visible = false;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
           
            
        }
    }
}